package com.yanqu.road.server.cmd.activity.share;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ShareProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.share.ShareModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/11/10 22:36
 */
@Cmd(code = GameProtocol.S_DY_BACK_REWARD, desc = "抖音回到游戏")
public class DyBackRewardCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(ShareModule.class).getDyBackReward();
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            ShareProto.SaveDeskRewardRespMsg.Builder respMsg = ShareProto.SaveDeskRewardRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(ClientProtocol.U_DY_BACK_REWARD, respMsg);
        }
    }
}
